package com.yangrui.app.controller;

import com.yangrui.app.entity.Video;
import com.yangrui.app.entity.eVideo;
import com.yangrui.app.service.VideoService;

import com.yangrui.app.service.esService;
import com.yangrui.app.util.Result;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


@RestController
@RequestMapping("/api/es")
public class ElasticSearchController {
    @Autowired
    private com.yangrui.app.service.esService esService;


    @GetMapping("/init")
    public String init(){
        esService.saveAll();
        return "success";
    }

    @GetMapping("/search")
    public Result search(String s){
        List<eVideo> search = esService.search(s);
        return Result.ok(search);
    }
}
